package leetcode100;

import java.util.Arrays;

public class lc018 {
    public static void main(String[] args) {
        int[] nums = new int[] {1,0,2,3,0,6,3,0};
        System.out.println(Arrays.toString(nums));
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }

    public static void moveZeroes(int[] nums) {
        int notZeroIndex = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]!=0) {
                nums[notZeroIndex] = nums[i];
                notZeroIndex++;
            }
        }
        Arrays.fill(nums,notZeroIndex,nums.length,0);
    }
}
